<!--阿里云配置-->
<template>
  <div class="ele-body">
    <el-row :gutter="15">
      <el-col :span="24">
        <el-card shadow="never"
                 body-style="padding: 0;">
          <el-tabs v-model="active"
                   class="user-info-tabs">
            <el-tab-pane label="提现金额配置"
                         name="1">
              <el-form ref="withdrawalForm"
                       :model="withdrawalForm"
                       :rules="rules"
                       label-width="180px"
                       style="max-width: 650px; padding: 34px 20px 0 20px"
                       @keyup.enter.native="save"
                       @submit.native.prevent>

                <el-form-item label="提现金额:"
                              prop="withdrawalAmount">
                  <el-input v-model="withdrawalForm.withdrawalAmount"
                            placeholder="请输入提现金额"
                            clearable />
                </el-form-item>
                <el-form-item>
                  <el-button type="primary"
                             :loading="loading"
                             @click="save('withdrawalForm')">
                    保存
                    <!-- {{maskerValueZfb=='1'?'保存新增':'保存更改' }} -->
                  </el-button>
                </el-form-item>
              </el-form>

            </el-tab-pane>

          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
	
	<script>
import { insertSelective, getWithdrawalamount } from '@/api/system/serviceProxyConfig'

export default {
  name: "index",
  data () {
    return {
      matchedProps: {},
      loading: false,
      active: '1', // tab页选中

      // 金额配置
      withdrawalForm: {

        withdrawalAmount: 0.01
      },

      // 表单验证规则
      rules: {
        // withdrawalAmount: [
        //   { required: true, message: '请输入提现金额', trigger: 'blur' },

        //   { type: 'number', message: '输入必须为数字' },
        // ],

      },

    }
  },
  computed: {
    // 是否开启响应式布局
    styleResponsive () {
      return this.$store.state.theme.styleResponsive;
    }
  },
  // 路由刷新
  activated () {

    this.init();


  },
  created () {
    // this.wxForm.payType = this.active;
    // this.zfbForm.payType = this.active;

    // if (localStorage.getItem('wxMarkers') == null) {
    //   localStorage.setItem('wxMarkers', JSON.stringify({
    //     masker: '1',
    //     id: ''
    //   }))

    // }
    // if (localStorage.getItem('zfbMarkers') == null) {
    //   localStorage.setItem('zfbMarkers', JSON.stringify({
    //     masker: '1',
    //     id: ''
    //   }))
    // }
    // // this.markers = localStorage.getItem('zfbMarkers')
    // this.init()
    // this.loadMaskerValue()
  },
  methods: {
    // loadMaskerValue () {
    //   const wxMasker = JSON.parse(localStorage.getItem('wxMarkers'));
    //   this.maskerValueWx = wxMasker ? wxMasker.masker : '';
    //   console.log(this.maskerValueWx)
    //   const zfbMasker = JSON.parse(localStorage.getItem('zfbMarkers'));
    //   this.maskerValueZfb = zfbMasker ? zfbMasker.masker : '';
    //   console.log(this.maskerValueZfb)
    // },
    // findMatchingProperties (obj1, obj2) {

    //   console.log(obj1, obj2)
    //   for (const prop in obj2) {
    //     if (obj1.hasOwnProperty(prop)) {
    //       obj2[prop] = obj1[prop];
    //     }
    //   }
    //   console.log(obj2)
    //   obj2.payType == '1' ? this.wxForm : this.zfbForm = obj2;
    // },
    async init () {
      const res = await getWithdrawalamount()
      console.log(res)
      if (res.code == 2000) {
        if (res.data.id) {
          this.withdrawalForm.id = res.data.id

        }
        this.withdrawalForm.withdrawalAmount = res.data.withdrawalAmount
        this.$nextTick(() => {
          this.$refs.withdrawalForm.clearValidate();
        })
        this.$message.success('查询成功')
      } else {
        this.$message.error(res.msg)
      }
    },
    // init () {
    //   if (JSON.parse(localStorage.getItem('wxMarkers')).id && this.active == '1') {
    //     getPayparameter({
    //       id: JSON.parse(localStorage.getItem('wxMarkers'))?.id
    //     })
    //       .then((res) => {
    //         console.log(this.active)

    //         this.findMatchingProperties(res.data, this.wxForm)
    //       })
    //       .catch((e) => {
    //         this.$message.error(e);
    //       });
    //   }
    //   if (JSON.parse(localStorage.getItem('zfbMarkers')).id && this.active == '2') {
    //     getPayparameter({
    //       id: JSON.parse(localStorage.getItem('zfbMarkers'))?.id
    //     })
    //       .then((res) => {
    //         console.log(this.active)

    //         this.findMatchingProperties(res.data, this.zfbForm)
    //       })
    //       .catch((e) => {
    //         this.$message.error(e);
    //       });
    //   }
    // },
    // handleClick (tab) {
    //   console.log(tab.name);
    //   this.init()
    //   this.active = tab.name
    //   this.wxForm.payType = this.active;
    //   this.zfbForm.payType = this.active;
    // },
    save (formName) {

      this.$refs[formName].validate(async (valid) => {
        if (!valid) {
          return false;
        }
        this.loading = true;

        const res = await insertSelective(this.withdrawalForm)

        console.log(res)

        if (res.code == 2000) {
          this.$message.success(res.msg)
        } else {
          this.$message.error(res.msg)
        }
        // const sumbitForm = this.active == '2' ? this.zfbForm : this.wxForm
        // const from = { ...sumbitForm, }
        // if (this.active == '1') {
        //   from.markers = JSON.parse(localStorage.getItem('wxMarkers')).masker
        //   if (JSON.parse(localStorage.getItem('wxMarkers')).masker == '2') {
        //     from.id = JSON.parse(localStorage.getItem('wxMarkers')).id
        //   }
        // } else {
        //   from.markers = JSON.parse(localStorage.getItem('zfbMarkers')).masker
        //   if (JSON.parse(localStorage.getItem('zfbMarkers')).masker == '2') {
        //     from.id = JSON.parse(localStorage.getItem('zfbMarkers')).id
        //   }
        // }
        // addPayparameter(from)
        //   .then((res) => {
        //     console.log(res)
        //     this.$message.success(res.msg)
        //     if (this.active == '1') {
        //       localStorage.setItem('wxMarkers', JSON.stringify({
        //         masker: '2',
        //         id: res.data
        //       }))
        //     } else {
        //       localStorage.setItem('zfbMarkers', JSON.stringify({
        //         masker: '2',
        //         id: res.data
        //       }))
        //     }


        //     this.init()
        this.loading = false;
        //     // 调用改变按钮(新增修改)的状态
        //     this.loadMaskerValue()
        //   })
        //   .catch((e) => {
        //     this.loading = false;
        //     this.$message.error(e);
        //   });
      });
    },
  }
}
	</script>
	
	<style lang="scss" scoped>
/* tab 页签 */
.user-info-tabs {
  :deep(.el-tabs__nav-wrap) {
    padding-left: 24px;
  }

  :deep(.el-tabs__item) {
    height: 50px;
    line-height: 50px;
    font-size: 15px;
  }
}
</style>
	